#include "stdafx.h"


#include "Game.h"

Game::Game(){
	mRenderer = new Renderer();

	/*
	//test
	float a[2][2] = {{1,2},{3,4}};
	typedef float bb [4];
	bb* b;
	b = (float(*)[4])(&a);
	int abc=0;
	//*b=(float*)a;	 //*/

}

Game::~Game(){
	assert(mRenderer!=NULL);
	delete mRenderer;
}

void Game::render_scene(){
	mRenderer->render_line(Vec3(-0.5,0.5,0), Vec3(0.5,0.5,0), Color(1,0,0));
	mRenderer->render_line(Vec3(0.5,0.5,0), Vec3(0.5,-0.5,0), Color(1,1,0));
	mRenderer->render_line(Vec3(0.5,-0.5,0), Vec3(-0.5,-0.5,0), Color(1,1,1));
	mRenderer->render_line(Vec3(-0.5,-0.5,0), Vec3(-0.5,0.5,0), Color(0,1,1));

	mRenderer->render_triangle(Vec3(-1,-1,0), Vec3(-1,1,0), Vec3(0,0,0), Color(1,0,0,0.5));
}

void Game::render(const float& elapsed){
	render_scene();
	mRenderer->render(elapsed);
}

void Game::surface_changed(const int& width, const int& height){
	mWidth = width;
	mHeight = height;
	mRenderer->resource_reset(mWidth, mHeight);
}

void Game::touch(const float& x, const float& y){
	mRenderer->render_line(Vec3(0,0,0), Vec3(x,y,0),Color(1,0,0));
	LOGI("mouse click %f %f\n",x, y);
}
